home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
071-080
/
amok71
/
cliutil
/
callint.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
4KB
|
111 lines
(* Module : CallInt
Author : Franz Schwarz
Address : Muehlenstrasse 2
Address : D-7201 Durchhausen
Address : Germany
email : FIDO: Franz Schwarz, 2:241/7506.18
email : uucp: Franz_Schwarz@p18.f7506.n241.z2.fidonet.org
Date : 07-May-92
Language: Oberon
Compiler: Amiga Oberon V2.14
Type : Small CLI utility
Legal : Released to the Public Domain
Required: AmigaOS 2.04 or higher
Info : This command just calls the resident INTERNAL command of the
Info : the same name as it was invoked with. It provides the ultimate
Info : solution for problems that arise from other programs which
Info : expect the respective command in the C: directory, although it
Info : may have become an internal resident command of Kickstart2.0 or
Info : higher. Since this program always calls the internal command
Info : in an documented and compliant and compatible way,
Info : all compatability problems have gone, as e.g. the old 1.3
Info : c:run command which still runs under 2.0 but doesn't propagate
Info : the alias list to the child process it invoces etc.
Info : Just copy this utility to c: with the respective name
Info : (e.g. 'copy CallInt c:Run') multiple times or simply copy it
Info : once and make links to it using 'makelink', e.g.:
Info : 'Copy CallInt c:, makelink c:run c:callint hard,
Info : makelink c:cd c:run hard' etc. BTW: Workbench start is
Info : detected and will result in an immediate return
Info :
Problems: None known
History : 20-Apr-92 First version, 38.0, always return NULL to the CLI
History : 21-Apr-92 Version 38.01, added return code classes as a
History : work around to the CLI return code problem
History : 23-Apr-92 Version 38.1, found the OberonLib.Result variable
History : CallInt now finally returns the correct CLI return code!
History : Initial public release!
History : 07-May-92 Fixed stack size bug, which was due to inconsitencies
History : in DOS structures (Process: size in bytes, CLI: size in longs
History : RunCommand: size in bytes)
*)
(* thoroughly tested, thus: *)
(* $OvflChk- $RangeChk- $StackChk- $NilChk- $ReturnChk- $CaseChk- *)
(* BTW: You should use SmallCode/SmallData!! *)
MODULE CallInt;
IMPORT S: SYSTEM, o: OberonLib, e: Exec, d: Dos;
CONST namBufSize = 1024;
version = "\000$VER: CallInternal 38.11 (07-May-92)";
VAR rc: LONGINT;
PROCEDURE main(): LONGINT;
VAR cmdseg: d.SegmentPtr;
rc, n: LONGINT;
nambuf, cmdnam, argstr: e.STRPTR;
me : d.ProcessPtr;
BEGIN
(* persuade Oberon to keep the version string in the executable *)
IF S.ADR(version)#NIL THEN END;
rc := 20;
IF (d.dos.lib.version >= 37) & ~o.wbStarted THEN
nambuf := e.AllocVec(namBufSize, e.any);
IF nambuf#NIL THEN
IF d.GetProgramName(nambuf^, namBufSize) THEN
cmdnam := d.FilePart(nambuf^);
e.Forbid();
cmdseg:=NIL;
LOOP
cmdseg := d.FindSegment(cmdnam^, cmdseg, d.DOSTRUE);
IF cmdseg = NIL THEN
EXIT;
ELSIF cmdseg.uc = d.cmdInternal THEN
EXIT;
END;
END;
e.Permit();
IF cmdseg#NIL THEN
argstr := o.dosCmdBuf;
me := S.VAL(d.ProcessPtr, o.Me);
rc := d.RunCommand (cmdseg.seg,ASH(me.cli.defaultStack,2),
argstr^, o.dosCmdLen);
ELSE
n:=d.Printf("Can't find INTERNAL %s\n", cmdnam);
n:=d.SetIoErr (d.objectNotFound);
END;
ELSE
n:=d.WriteStr ("Can't get program name\n"); (* IoErr already set by
Dos.GetProgramName() *)
END;
e.FreeVec(nambuf);
ELSE
n:=d.WriteStr ("No memory for command name buffer\n");
n:=d.SetIoErr (d.noFreeStore);
END;
END;
RETURN rc;
END main;
BEGIN
o.Result:=main();
END CallInt.